# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>

pkgname=srt
pkgver=1.3.1
pkgrel=1
pkgdesc="Secure Reliable Transport library"
url="https://www.srtalliance.org/"
arch=(x86_64)
license=(MPL2)
depends=(openssl)
makedepends=(git cmake ninja)
_commit=d6499ca374fe1bff5ccfd959786309b18a8e7388  # tags/v1.3.1
source=("git+https://github.com/Haivision/srt#commit=$_commit"
        no-rpath.diff)
sha256sums=('SKIP'
            'ce9a97d661d796da85a7e4faf9c70c27368d00eb505f85c03a31bba8f22e6847')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^v//;s/-/+/g'
}

prepare() {
  mkdir build
  cd $pkgname
  patch -Np1 -i ../no-rpath.diff
}

build() {
  cd build
  cmake -G Ninja ../srt \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_BINDIR=bin \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DCMAKE_INSTALL_INCLUDEDIR=include \
    -DENABLE_TESTING=True
  cmake --build .
}

check() {
  cd build
  ./utility-test
}

package() {
  DESTDIR="$pkgdir" cmake --build build --target install
  rm "$pkgdir"/usr/bin/*-test

  # Build tries this but fails when DESTDIR is set
  ln -s srt-live-transmit "$pkgdir/usr/bin/stransmit"
}

# vim:set ts=2 sw=2:
